package com.gx.smart.construction.ui.common.page.adapter;

import android.content.Context;
import android.view.View;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.gx.smart.base.BaseAdapter;
import com.gx.smart.construction.R;
import com.gx.smart.construction.databinding.ItemRoomItemLayoutBinding;
import com.gx.wisestone.constructionappgrpclib.grpc.organizationalstructure.ConstructionAppOrganizationalStructureDto;

/**
 * @author: xiaosy
 * 时间: 2021/11/19
 * @Description: java类作用描述
 * @Version: 1.0
 **/
public class RoomListAdapter extends BaseAdapter<ConstructionAppOrganizationalStructureDto,
        RoomListAdapter.ViewHolder>
        implements Filterable {
    private RoomListFilter roomListFilter;
    public RoomListAdapter(Context context) {
        super(context);
    }

    @Override
    protected int onBindLayout() {
        return R.layout.item_room_item_layout;
    }

    @Override
    protected ViewHolder onCreateHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected void onBindData(ViewHolder holder,
                              ConstructionAppOrganizationalStructureDto item, int position) {
        holder.room.setText(item.getNumber());
    }

    @Override
    public Filter getFilter() {
        if(roomListFilter == null){
            roomListFilter = new RoomListFilter(this);
        }
        return roomListFilter;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView room;
        ViewHolder(View view) {
            super(view);
            room = view.findViewById(R.id.room);
        }
    }
}
